!function(a) {
    function b(a) {
        window.console && window.console.log && window.console.log(a);
    }
    function c() {
        var a = this;
        c.inst = a, setInterval(function() {
            a.update(a);
        }, 200);
    }
    function d(a) {
        var b = a.match(/[\/\\]*([^\/\\]+)\.(png|jpg|jpeg|gif)$/i);
        return b && b[1] || "";
    }
    c.prototype = {
        _skinList: {},
        _ctrls: {},
        _wlQueue: [],
        addControl: function(b, c, e) {
            var f, g, h;
            if (null != b && !this.hasControl(b.id)) {
                f = c.split(";"), g = this, this._ctrls[b.id] = {
                    skinList: {},
                    skinSyn: f.length,
                    skinUrlList: [],
                    items: []
                }, h = function(a) {
                    return function(b) {
                        _ctrl = g.getControl(a.id), _ctrl.skinList[d(b.src)] = b, 0 == --_ctrl.skinSyn && e(a, _ctrl.skinList[_ctrl.skinUrlList[0]]);
                    };
                };
                for (idx in f) url = a.trim(f[idx]), this._ctrls[b.id].skinUrlList.push(d(url)), 
                "" !== url && this.loadSkin(b, url, h(b));
            }
        },
        getControl: function(a) {
            return this._ctrls[a];
        },
        hasControl: function(a) {
            return void 0 != this._ctrls[a];
        },
        addItem: function(a, b, c) {
            this.hasControl(a) && this._ctrls[a].items.push({
                ref: b,
                onProgress: c
            });
        },
        progress: function(a, b) {
            if (this.hasControl(a)) {
                var b = isFinite(b) ? Math.max(Math.min(b, 100), 0) : 0;
                for (i = 0; i < this._ctrls[a].items.length; ++i) this._ctrls[a].items[i].onProgress(this._ctrls[a].items[i].ref, b);
            }
        },
        update: function(b) {
            var d, e, c = [];
            for (d = 0; d < b._wlQueue.length; ++d) e = b._skinList[b._wlQueue[d].url], e && 1 == e.state && (c.push(d), 
            b._wlQueue[d].cb(e.img));
            c.length > 0 && (this._wlQueue = a.grep(this._wlQueue, function(b, d) {
                return -1 == a.inArray(d, c);
            }));
        },
        loadSkin: function(c, d, e) {
            var f, g;
            d = d, void 0 == this._skinList[d] ? (f = document.createElement("img"), g = a(f), 
            g.css({
                visibility: "hidden",
                position: "absolute"
            }), this._skinList[d] = {
                img: f,
                state: 0
            }, g.load(function(a) {
                return function() {
                    a.state = 1, e(a.img);
                };
            }(this._skinList[d])), g.error(function() {
                b("unable to load skin '" + this.src + "'");
            }), f.src = d, a(c).before(g)) : this._wlQueue.push({
                url: d,
                cb: e
            });
        }
    }, a.fn.progressCtrl = function(b, d) {
        function i(b, c) {
            function l(f) {
                var i, k;
                0 != h.useCaps && 0 != d && (posy = 2 * -g, i = a("<div />"), i.attr("id", b.id + "-cap-" + f), 
                i.css({
                    width: d + "px",
                    height: g + "px",
                    padding: "0",
                    margin: "0",
                    "float": "left"
                }), i.css("background-image", "url(" + c.src + ")"), i.css("overflow", "hidden"), 
                k = function(a, b, c) {
                    return function(d, e) {
                        var f = "left" == a ? 0 == e ? 0 : 1 : 100 == e ? 3 : 2;
                        d.css("background-position", -f * b + "px " + c + "px");
                    };
                }(f, d, posy), e.addItem(b.id, i, k), j.append(i));
            }
            var d, f, g, i, j, k, m, n, o;
            e.hasControl(b.id) && (d = h.capWidth || c.width / 4, f = Math.max(h.width, 2 * d + 2), 
            g = h.height || c.height / (h.useCaps ? 3 : 2), i = h.useCaps ? f - 2 * d : f, j = a("<div />"), 
            j.css({
                width: f + "px",
                height: g + "px",
                padding: "0"
            }), "" === h.title ? e.addItem(b.id, j, function(a, b) {
                a.attr("title", b + "%");
            }) : j.attr("title", h.title), k = a("#" + b.id + "-label"), h.label && k.is("span") && e.addItem(b.id, k, function(a, b) {
                a.text(b + "%");
            }), j.addClass(h.containerClass), l("left"), m = a("<div />"), m.attr("id", b.id + "-track"), 
            m.css({
                width: i + "px",
                height: g + "px",
                padding: "0",
                margin: "0",
                "float": "left"
            }), m.css("overflow", "hidden"), m.css("background", "transparent url(" + c.src + ") repeat-x left " + (-g).toString() + "px"), 
            j.append(m), n = a("<div />"), n.attr("id", b.id + "-ctrl"), n.css({
                width: i + "px",
                height: g + "px",
                padding: "0",
                margin: "0"
            }), n.css("background", "transparent url(" + c.src + ") repeat-x left top"), o = function(a) {
                return function(b, c) {
                    var d = Math.ceil(a * (c / 100));
                    b.css("margin-left", d + "px");
                };
            }(i, null), e.addItem(b.id, n, o), m.append(n), l("right"), e.progress(b.id, h.pos), 
            a(b).append(j));
        }
        function j(b, c) {
            function f(e) {
                var f = a("#" + (b.id + "-" + e)), g = d.skinList[d.skinUrlList[c]];
                f.is("div") && f.css("background-image", "url(" + g.src + ")");
            }
            var d = e.getControl(b.id);
            c = "number" != typeof c ? 0 : c, d && c >= 0 && c < d.skinUrlList.length && (f("cap-left"), 
            f("track"), f("ctrl"), f("cap-right"));
        }
        function k(a, b) {
            e.progress(a.id, b);
        }
        var e = void 0 != c.inst ? c.inst : new c(), f = function() {
            return "string" == typeof b ? {
                setter: b,
                args: d
            } : b || {};
        }, g = "number" == typeof b ? a.extend({
            pos: b
        }, d || {}) : f(), h = a.extend({
            pos: 0
        }, a.fn.progressCtrl.defaults, g), l = {
            skinIdx: j,
            progress: k
        };
        return this.each(function() {
            var b = this;
            e.hasControl(this.id) ? "string" == typeof h.setter && void 0 != l[h.setter] ? l[h.setter](b, h.args || []) : e.progress(b.id, h.pos) : (a(b).empty(), 
            e.addControl(b, h.skin, i));
        });
    }, a.fn.progressCtrl.defaults = {
        skin: "",
        width: 100,
        height: 0,
        useCaps: !0,
        capWidth: 0,
        title: "",
        containerClass: "pbContainer",
        label: !0
    };
}(jQuery);